﻿using System.ComponentModel.DataAnnotations;
using WebApplication1.Core.Domain.Entities;

namespace WebApplication1.Core.DataTransferObject {
    public class LouYuanRequest {

        public ushort? LouYuanID { get; set; }

        [Required(ErrorMessage = "社区名称不能为空")]
        public string MingCheng { get; set; }

        public int? FangWuShuLiang { get; set; }

        public int? DongShu { get; set; }

        public float? JianZhuMianJi { get; set; }

        public string? JianChengShiJian { get; set; }

        public ushort? SheQuID { get; set; }

        public string? DiZhi { get; set; }


        public LouYuan ToLouYuan() {
            if(this.LouYuanID != null) {
                return new LouYuan() {
                    LouYuanID = this.LouYuanID!.Value,
                    MingCheng = this.MingCheng,
                    FangWuShuLiang = this.FangWuShuLiang,
                    DongShu = this.DongShu,
                    JianZhuMianJi = this.JianZhuMianJi,
                    JianChengShiJian = this.JianChengShiJian,
                    SheQuID = this.SheQuID,
                    DiZhi = this.DiZhi
                };
            } else {
                return new LouYuan() {
                    MingCheng = this.MingCheng,
                    FangWuShuLiang = this.FangWuShuLiang,
                    DongShu = this.DongShu,
                    JianZhuMianJi = this.JianZhuMianJi,
                    JianChengShiJian = this.JianChengShiJian,
                    SheQuID = this.SheQuID,
                    DiZhi = this.DiZhi
                };
            }
        }

        public LouYuanResponse toLouYuanResponse() {
            if(this.LouYuanID != null) {
                return new LouYuanResponse() {
                    LouYuanID = this.LouYuanID!.Value,
                    MingCheng = this.MingCheng,
                    FangWuShuLiang = this.FangWuShuLiang,
                    DongShu = this.DongShu,
                    JianZhuMianJi = this.JianZhuMianJi,
                    JianChengShiJian = this.JianChengShiJian,
                    SheQuID = this.SheQuID,
                    DiZhi = this.DiZhi
                };
            } else {
                return new LouYuanResponse() {
                    MingCheng = this.MingCheng,
                    FangWuShuLiang = this.FangWuShuLiang,
                    DongShu = this.DongShu,
                    JianZhuMianJi = this.JianZhuMianJi,
                    JianChengShiJian = this.JianChengShiJian,
                    SheQuID = this.SheQuID,
                    DiZhi = this.DiZhi
                };
            }
        }
    }
}
